package com.cts.c2;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.Menu;
import android.support.v4.view.MenuItem;
import android.support.v4.view.Window;
import android.support.v4.view.MenuItem.OnMenuItemClickListener;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class HomeActivity extends FragmentActivity {
	private static final int SHOW_STREAM = 1;
	private static final int SHOW_PROFILE = 2;
	private static final int SHOW_CWEET_POST = 3;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_ACTION_BAR_ITEM_TEXT);
		setContentView(R.layout.home);

		Button streambtn = (Button) findViewById(R.id.streambtn);
		streambtn.setOnClickListener(streamBtnListner);

	}

	private OnClickListener streamBtnListner = new OnClickListener() {
		public void onClick(View v) {
			Intent myIntent = new Intent();
			myIntent.setClassName("com.cts.c2", "com.cts.c2.StreamActivity");
			startActivityForResult(myIntent, SHOW_STREAM);
		}
	};

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		menu.add("Cweet").setIcon(R.drawable.ic_action_mark)
				.setOnMenuItemClickListener(menuItemClickListener)
				.setShowAsAction(
						MenuItem.SHOW_AS_ACTION_ALWAYS
								| MenuItem.SHOW_AS_ACTION_WITH_TEXT);

		return super.onCreateOptionsMenu(menu);
	}

	private OnMenuItemClickListener menuItemClickListener = new OnMenuItemClickListener() {

		@Override
		public boolean onMenuItemClick(MenuItem item) {
			Intent myIntent = new Intent();
			myIntent.setClassName("com.cts.c2", "com.cts.c2.CweetPostActivity");
			startActivityForResult(myIntent, SHOW_CWEET_POST);
			return true;
		}

	};

}
